$(function(){

	var detailId=queryString('detailId');
	requestDetail(detailId);
	
})
//分页，首页
  $("#headPage").click(function(){
  	page=1;
  	$("#totalPage").html(page+"/"+totalPage);
  	requestPage(page);
  })
  //分页，尾页
  $("#endPage").click(function(){
  	$("#totalPage").html(totalPage+"/"+totalPage);
  	page=totalPage;
  	requestPage(page);
  })
  //分页，上一页
  $("#prevPage").click(function(){
  	if(page<=1)
  	{
  		page=1;
  	}
  	else
  	{
  		page=page-1;
  		$("#totalPage").html(page+"/"+totalPage);
  		requestPage(page);
  	}

 })
  //分页，下一页
   $("#nextPage").click(function(){
  	
  	if(page>=totalPage)
  	{
  		page=page-1;
  	}
  	else
  	{
  		page=page+1;
  		$("#totalPage").html(page+"/"+totalPage);
  		requestPage(page);
  	}
  	
  })

//分页
function requestPage(page)
{
	$("#tablebody").html("");
	var dapage={currentPage:page};
	var url="/yuxi/LoginFilter/getUserInformation.do";
	/*------*/								
	YuXi.util.get(url,dapage,function(data){
		object=data.list;
		for(var i=0;i<object.length;i++)
		{
			var time=YuXi.getTime.get(object[i].createTime);
			alert(time);
			if( object[i].informationProfile.length>15)
				object[i].informationProfile= object[i].informationProfile.substring(0,15)+"...";
			var html="<tr ><td>"+(i+1)+"</td><td >"+object[i].informationProfile+"</td>"+
				"<td >"+time+"</td><td>"+object[i].flowName+"</td>"+
				"<td><a data-id="+object[i].id+" href='javascript:void(0)'; class='detail'>详情</a></td></tr>";
			$("#tablebody").append(html);
		}
	 },function(){
	 })
}
//正则取链接传来的数据
function queryString(key)
{
    var regex_str = "^.+\\?.*?\\b"+ key +"=(.*?)(?:(?=&)|$|#)"
    var regex = new RegExp(regex_str,"i");
    var url = window.location.toString();
    if(regex.test(url)) return RegExp.$1;
    return undefined;
}
//根据id向后台请求数据详情
function requestDetail(id)
{
	//数据模拟
	var object={id:1,informationSource:"已审核安全排查",safetyPort:"日搜日结",
			informationSort:"情报",informationClassification:"三级",
			inputPerson:"xxxx,xxx",informationProfile:"xsdadiao",
			Standard:"xdadabiao",Measure:"措施",informationContent:"xsdaaxdsadas",
			appendix:["/yuxi/vedioo/xuqin.mp4","/yuxi/vedioo/11.jpg"]
	};
	$("#valSource").html(object.informationSource);//渠道
	$("#valPort").html(object.safetyPort);//分口
	$("#valSort").html(object.informationSort);//分类
	$("#valClassification").html(object.informationClassification);//分级
	$("#valPerson").html(object.inputPerson);//参与人
	$("#valProfile").html(object.informationProfile);//简介
	$("#valStandard").html(object.Standard);//标准
	$("#valMeasure").html(object.Measure);//措施
	$("#valContent").html(object.informationContent);//内容
	YuXi.appendix.get(object.appendix);
	
}